<ui:composition template="/WEB-INF/template/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                xmlns:sgbd="http://java.sun.com/jsf/composite/components">

    <ui:define name="title">Comptes</ui:define>

    <ui:define name="navigator">
        <sgbd:navigator comptes="active" />
    </ui:define>

    <ui:define name="content">
        <h:form>
            <h2>Connexion Oracle</h2>
            <h:outputText value="Base #{compteBean.current.name}" />
            <h:commandLink action="#{oracleConnect.deconnectFromWeb()}">
                <h:graphicImage library="images" name="disconnect.gif" alt="Déconnexion" />
            </h:commandLink>
            <br /><br />

            <rich:panel header="Administrateur">
                <rich:tabPanel switchType="client">
                    <rich:tab header="Sauvegarde">
                        <h3>Sauvegarde à froid de la base de données</h3>
                        <br />
                        <h:panelGrid columns="3">
                            <h:outputText value="Chemin où sauvegarder les fichiers " />
                            <h:inputText value="#{oracleConnect.backupColdPath}"
                                         required="true"
                                         requiredMessage="Veuillez indiquer un chemin de sauvegarde des fichiers"
                                         id="backupColdPath" />
                            <rich:message for="backupColdPath" ajaxRendered="true" />
                            
                            <h:outputText value="Chemin du répertoire où se trouve init#{oracleConnect.dbName}.ora" />
                            <h:inputText value="#{oracleConnect.startupPath}"
                                         required="true"
                                         requiredMessage="Veuillez indiquer le chemin demandé"
                                         id="startupOraclePath" />
                            <rich:message for="startupOraclePath" ajaxRendered="true" />
                        </h:panelGrid>
                        <h:commandLink action="#{oracleConnect.saveBackupColdScript()}">
                            <h:graphicImage library="images"
                                            name="save.png" />
                        </h:commandLink>
                    </rich:tab>
                    <rich:tab header="Tablespaces">
                        <h3>Tablespaces</h3>
                        <rich:dataTable value="#{oracleConnect.allTableSpace}" 
                                        var="tableSpaceOracle"
                                        rowClasses="even,odd"
                                        styleClass="dataTable">
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Name" />
                                </f:facet>
                                <h:outputText value="#{tableSpaceOracle.name}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Nom de fichier" />
                                </f:facet>
                                <h:outputText value="#{tableSpaceOracle.fileName}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Alloué (Mo)" />
                                </f:facet>
                                <h:outputText value="#{tableSpaceOracle.total}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Taille maximale (Mo)" />
                                </f:facet>
                                <h:outputText value="#{tableSpaceOracle.maxSize}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Occupé (Mo)" />
                                </f:facet>
                                <h:outputText value="#{tableSpaceOracle.busy}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Libre (Mo)" />
                                </f:facet>
                                <h:outputText value="#{tableSpaceOracle.free}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Pourcentage" />
                                </f:facet>
                                <h:outputText value="#{tableSpaceOracle.percent}%" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Auto-extensible" />
                                </f:facet>
                                <h:outputText value="#{tableSpaceOracle.autoextensible}" />
                            </rich:column>
                        </rich:dataTable>
                    </rich:tab>
                    <rich:tab header="Mémoire">
                        <h3>Mémoire</h3>
                        <h:outputText value="Taille de la mémoire (Mo) : " />
                        <h:outputText value="#{oracleConnect.memoryInfo}" />
                        <br /><br />
                        <rich:dataTable styleClass="dataTable"
                                        value="#{oracleConnect.sgaDetails}"
                                        var="sgaDetails"
                                        rowClasses="even,odd">
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Name" />
                                </f:facet>   
                                <h:outputText value="#{sgaDetails.name}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Description" />
                                </f:facet>
                                <h:outputText value="#{sgaDetails.description}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Display value" />
                                </f:facet>
                                <h:outputText value="#{sgaDetails.displayValue}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Value" />
                                </f:facet>
                                <h:outputText value="#{sgaDetails.value}" />
                            </rich:column>
                        </rich:dataTable>
                    </rich:tab>
                    <rich:tab header="Instances">
                        <h3>Instances</h3>
                        <rich:dataTable value="#{oracleConnect.allInstanceOracle}" 
                                        var="instanceOracle"
                                        rowClasses="even,odd"
                                        styleClass="dataTable">
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Numéro de l'instance" />
                                </f:facet>
                                <h:outputText value="#{instanceOracle.instanceNumber}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Nom de l'instance" />
                                </f:facet>
                                <h:outputText value="#{instanceOracle.instanceName}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="ActiveState" />
                                </f:facet>
                                <h:outputText value="#{instanceOracle.activeState}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Version" />
                                </f:facet>
                                <h:outputText value="#{instanceOracle.version}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Database status" />
                                </f:facet>
                                <h:outputText value="#{instanceOracle.dataBaseStatus}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Hostname" />
                                </f:facet>
                                <h:outputText value="#{instanceOracle.hostName}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Rôle de l'instance" />
                                </f:facet>
                                <h:outputText value="#{instanceOracle.instanceRole}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="StartupTime" />
                                </f:facet>
                                <h:outputText value="#{instanceOracle.startupTime}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Status" />
                                </f:facet>
                                <h:outputText value="#{instanceOracle.status}" />
                            </rich:column>
                        </rich:dataTable>
                    </rich:tab>
                    <rich:tab header="Utilisateurs">
                        <h3>Utilisateurs et leurs caractéristiques</h3>
                        <rich:dataTable value="#{oracleConnect.allUser}"
                                        var="caracteristicUser"
                                        rowClasses="even,odd"
                                        styleClass="dataTable">
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Username" />
                                </f:facet>
                                <h:outputText value="#{caracteristicUser.name}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Id" />
                                </f:facet>
                                <h:outputText value="#{caracteristicUser.id}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Account status" />
                                </f:facet>
                                <h:outputText value="#{caracteristicUser.accountStatus}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Default tablespace" />
                                </f:facet>
                                <h:outputText value="#{caracteristicUser.defaultTablespace}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Temporary tablespace" />
                                </f:facet>
                                <h:outputText value="#{caracteristicUser.temporaryTablespace}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Authentification type" />
                                </f:facet>
                                <h:outputText value="#{caracteristicUser.authenticationType}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Profile" />
                                </f:facet>
                                <h:outputText value="#{caracteristicUser.profile}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Created date" />
                                </f:facet>
                                <h:outputText value="#{caracteristicUser.createdDate}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Expiry date" />
                                </f:facet>
                                <h:outputText value="#{caracteristicUser.expiryDate}" />
                            </rich:column>
                        </rich:dataTable>
                        <br />
                        <h3>Utilisateurs et leurs objets</h3>
                        <rich:dataTable value="#{oracleConnect.allUser}" 
                                        var="userOracle"
                                        rowClasses="even,odd"
                                        styleClass="dataTable">
                            <f:facet name="header">
                                <rich:columnGroup>
                                    <rich:column colspan="2">
                                        <h:outputText value="Utilisateurs" />
                                    </rich:column>
                                    <rich:column breakRowBefore="true">
                                        <h:outputText value="Objet" />
                                    </rich:column>
                                    <rich:column>
                                        <h:outputText value="Nombre" />
                                    </rich:column>
                                </rich:columnGroup>
                            </f:facet>
                            <rich:column colspan="2">
                                <rich:collapsibleSubTableToggler for="oracleObjectByUser" />
                                <h:outputText value="#{userOracle.name}" />
                            </rich:column>
                            <rich:collapsibleSubTable value="#{userOracle.objectOracle}"
                                                      var="objectByUser"
                                                      expanded="#{false}"
                                                      id="oracleObjectByUser"                                          
                                                      expandMode="client">
                                <rich:column>
                                    <h:outputText value="#{objectByUser.type}" />
                                </rich:column>
                                <rich:column>
                                    <h:outputText value="#{objectByUser.count}" />
                                </rich:column>
                                <f:facet name="footer">
                                    <h:outputText value="Total : #{userOracle.totalCountObject}" />
                                </f:facet>
                            </rich:collapsibleSubTable>
                        </rich:dataTable>
                        <br />
                        <h3>Utilisateurs et rôles</h3>
                        <rich:dataTable value="#{oracleConnect.allUser}" 
                                        var="userOracleRole"
                                        styleClass="dataTable"
                                        rowClasses="even,odd">
                            <f:facet name="header">
                                <rich:columnGroup>
                                    <rich:column colspan="1">
                                        <h:outputText value="Utilisateurs" />
                                    </rich:column>
                                    <rich:column breakRowBefore="true">
                                        <h:outputText value="Rôle" />
                                    </rich:column>
                                </rich:columnGroup>
                            </f:facet>
                            <rich:column colspan="1">
                                <rich:collapsibleSubTableToggler for="oracleRoleByUser" />
                                <h:outputText value="#{userOracleRole.name}" />
                            </rich:column>
                            <rich:collapsibleSubTable value="#{userOracleRole.roles}"
                                                      var="oracleRoleByUser"
                                                      expanded="#{false}"
                                                      id="oracleRoleByUser"                                          
                                                      expandMode="client">
                                <rich:column>
                                    <h:outputText value="#{oracleRoleByUser}" />                            
                                </rich:column>
                            </rich:collapsibleSubTable>
                        </rich:dataTable>
                        <br />
                        <h3>Utilisateurs et privilèges</h3>
                        <rich:dataTable value="#{oracleConnect.allUser}" 
                                        var="userOraclePrivilege"
                                        styleClass="dataTable"
                                        rowClasses="even,odd">
                            <f:facet name="header">
                                <rich:columnGroup>
                                    <rich:column colspan="1">
                                        <h:outputText value="Utilisateurs" />
                                    </rich:column>
                                    <rich:column breakRowBefore="true">
                                        <h:outputText value="Privilège" />
                                    </rich:column>
                                </rich:columnGroup>
                            </f:facet>
                            <rich:column colspan="1">
                                <rich:collapsibleSubTableToggler for="oraclePrivilegeByUser" />
                                <h:outputText value="#{userOraclePrivilege.name}" />
                            </rich:column>
                            <rich:collapsibleSubTable value="#{userOraclePrivilege.privileges}"
                                                      var="oraclePrivilegeByUser"
                                                      expanded="#{false}"
                                                      id="oraclePrivilegeByUser"                                          
                                                      expandMode="client">
                                <rich:column>
                                    <h:outputText value="#{oraclePrivilegeByUser}" />                            
                                </rich:column>
                            </rich:collapsibleSubTable>
                        </rich:dataTable>
                    </rich:tab>
                    <rich:tab header="Autres bases de données">
                        <h3>Liens vers les autres base de données</h3>
                        <rich:dataTable value="#{oracleConnect.allDbLinksOracle}" 
                                        var="dbLinksOracle"
                                        styleClass="dataTable"
                                        rowClasses="even,odd">
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Owner" />
                                </f:facet>
                                <h:outputText value="#{dbLinksOracle.owner}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Link" />
                                </f:facet>
                                <h:outputText value="#{dbLinksOracle.link}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Username" />
                                </f:facet>
                                <h:outputText value="#{dbLinksOracle.username}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Host" />
                                </f:facet>
                                <h:outputText value="#{dbLinksOracle.host}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:outputText value="Created" />
                                </f:facet>
                                <h:outputText value="#{dbLinksOracle.created}" />
                            </rich:column>
                        </rich:dataTable> 
                    </rich:tab>                    
                </rich:tabPanel>
            </rich:panel>
        </h:form>
    </ui:define>
</ui:composition>